﻿@using Apps.Web.Core;
@using Apps.Common;
@using Apps.Models.PUB;
@using Apps.Web;
@using Apps.Locale;
@using Apps.Models.Sys;
@using Apps.Models.Enum;
@using Apps.Models
@{
    ViewBag.Title = "创建";
    Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
    List<permModel> perm = null;
    var fieldList = ViewBag.FieldList as List<V_HC_ITEM_FIELD_VALUE>;//ViewBag.FieldList as HC_ITEM_FIELD_VO;
    var itemId = ViewBag.itemId as string;
}

<script type="text/javascript">
    $(function () {
        $("#btnSave").click(function () {
            if ($("form").valid()) {
                $.ajax({
                    url: "@Url.Action("Create")",
                    type: "Post",
                    data: $("form").serialize(),
                    dataType: "json",
                    success: function (data) {
                        if (data.type == 1) {
                            window.parent.frameReturnByMes(data.message);
                            window.parent.frameReturnByReload(true);
                            window.parent.frameReturnByClose()
                        }
                        else {
                            window.parent.frameReturnByMes(data.message);
                        }
                    }
                });
            }
            return false;
        });
        $("#btnReturn").click(function () {
            window.parent.frameReturnByClose();
        });
    });
</script>
<div class="mvctool bgb">
    @Html.ToolButton("btnSave", "fa fa-save", Resource.Save, ref perm, "Save", true)
    @Html.ToolButton("btnReturn", "fa fa-reply", Resource.Reply, false)
</div>
@using (Html.BeginForm())
{
    @Html.Hidden("itemId", @itemId)
    <table class="formtable">
        <tbody>
            @foreach (var item in fieldList)
            {
                <tr>
                    <th>
                        <label for="@item.NAME">
                            @if (@item.IS_REQUIRED == 1)
                            {
                                <font color="red">*</font>
                            }
                            @item.TITLE
                        </label>：
                    </th>
                    <td>

                        @if (item.IS_REQUIRED == 1)//必填
                        {
                            if (item.CONTROL_TYPE == 1)//单行文本
                            {
                                <input class="text-box single-line" data-val="true" data-val-required="字段是必需的。" id="@item.NAME" name="@item.NAME" type="text" value="" autocomplete="off">
                            }
                            else if (@item.CONTROL_TYPE == 3)//时间
                            {
                                <input id="@item.NAME" name="@item.NAME" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" type="text" class="searchText" data-options="required:true" style="width:100px"/>

                            }
                            else
                            {
                                <input class="easyui-numberbox" data-val="true" data-val-required="字段是必需的。" validType:'email' precision="3" min="0" id="@item.NAME" name="@item.NAME" type="text" value="" autocomplete="off">
                                if (Utils.ObjToDecimal(item.MAXVALUE, 0) > 0)
                                {
                                    <font color="red">(@Utils.ObjToDecimal(item.MINVALUE, 0)-@Utils.ObjToDecimal(item.MAXVALUE, 0))</font>
                                }
                            }
                        }
                        else
                        {
                            if (item.CONTROL_TYPE == 1)//单行文本
                            {
                                <input class="text-box single-line" id="@item.NAME" name="@item.NAME" type="text" value="" autocomplete="off">
                            }
                            else if (@item.CONTROL_TYPE == 3)//时间
                            {
                                <input id="@item.NAME" name="@item.NAME" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" type="text" class="searchText" data-options="required:true" style="width:100px"  />

                            }
                            else
                            {
                                <input class="easyui-numberbox" precision="3" min="0" id="@item.NAME" name="@item.NAME" type="text" value="" autocomplete="off">
                                if (Utils.ObjToDecimal(item.MAXVALUE, 0) > 0)
                                {
                                    <font color="red">(@Utils.ObjToDecimal(item.MINVALUE, 0)-@Utils.ObjToDecimal(item.MAXVALUE, 0))</font>
                                }
                            }
                        }
                    </td>
                </tr>
            }
        </tbody>
    </table>
    @Html.ValidationSummary()
}

